package com.system.insurance.controller;


import com.system.common.result.Result;
import com.system.insurance.entity.Slideshow;
import com.system.insurance.service.SlideshowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 轮播图 前端控制器
 * </p>
 *
 * @author WS
 * @since 2024-05-10
 */
@Api(tags = "轮播图")
@RestController
@RequestMapping("/slideshow")
public class SlideshowController {

    @Autowired
    private SlideshowService slideshowService;

    @ApiOperation("查看轮播图")
    @GetMapping
    public Result<List<Slideshow>> slideshowselect(){
        List<Slideshow> list = slideshowService.list();
        return Result.ok(list);
    }

    @ApiOperation("轮播图修改")
    @PostMapping
    public Result<Slideshow> slideshowselect(@RequestBody Slideshow slideshow){

        slideshow.setUpdateTime(LocalDateTime.now());
        boolean byId = slideshowService.updateById(slideshow);
        if(byId){
            return Result.ok(slideshow).message("修改成功");
        }
        return Result.fail(slideshow).message("修改失败");
    }

}

